// 统一管理 发日常帖 请求方法

import {
  baseUrl
} from "@/config/baseUrl";
import {
  request
} from "@/utils/request";

const API = {
  PUBLISHDAILYBLOG: "/dailyBlog/publish/", // 发布日常帖
  UPLOADPICTURE: baseUrl + "/upload/images" // 上传图片
}

// 发布约球帖
export const reqPublishDailyBlog = (type, data) => request({
  url: API.PUBLISHDAILYBLOG + type,
  method: "POST",
  data: data
})

// 上传图片
export const reqUploadPicture = (path) => {
  return new Promise((resolve, reject) => {
    uni.uploadFile({
      url: API.UPLOADPICTURE,
      filePath: path,
      name: 'file',
      header: {
        'Authorization': '' + wx.getStorageSync('sessionID')
      },
      success: (res) => {
        resolve(res.data)
      },
      fail: (error) => {
        reject(error)
      }
    })
  })
}